//
//  UIView+addLine.m
//  SSJC
//
//  Created by xzm on 16/11/8.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "UIView+addLine.h"
#import <objc/runtime.h>

const void *CustomActionSheetFinishBlock = &CustomActionSheetFinishBlock;
const void *CustomActionSheetTitleArray = &CustomActionSheetTitleArray;
const void *CustomActionSheetTargetView = &CustomActionSheetTargetView;

@interface UIView ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation UIView (addLine)

- (void)addLine{
    
    [self addLineWithFrame:CGRectMake(0, self.height-0.5, self.width, 0.5) color:sepeLineColor];
}

/**
 右边加竖线
 */
- (void)addVerticalLine{
    
    [self addLineWithFrame:CGRectMake(self.width - 0.5, 0, 0.5, self.height) color:sepeLineColor];
    
}

- (void)addLineWithFrame:(CGRect)rect color:(UIColor *)color{
    
    UIView *line = [[UIView alloc]initWithFrame:rect];
    line.backgroundColor = color;
    [self addSubview:line];
}



/**
 设置边框
 
 @param borderColor 边框颜色
 @param borderWidth 边框宽度
 */
- (void)setBorderWithColor:(UIColor *)borderColor borderWidth:(CGFloat)borderWidth{
    
    self.layer.borderWidth = borderWidth;
    self.layer.borderColor = borderColor.CGColor;
    self.layer.masksToBounds = YES;
}


/**
 设置不同方向圆角

 @param corners 圆角方向
 @param radius  角度
 */
-(void)setRoundedCorners:(UIRectCorner)corners radius:(CGFloat)radius {
    CGRect rect = self.bounds;
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect
                                                   byRoundingCorners:corners
                                                         cornerRadii:CGSizeMake(radius, radius)];
    
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = rect;
    maskLayer.path = maskPath.CGPath;
    
    self.layer.mask = maskLayer;
}



@end
